/*
 * @Autor: xgq
 * @Description: 
 * @Version: 1.0
 * @Date: 2020-05-11 09:26:51
 * @LastEditors: xgq
 * @LastEditTime: 2020-05-11 09:56:29
 */
const Sequelize = require('sequelize')

module.exports = (sequelize, DataTypes) => {

  class m_admin extends Sequelize.Model {

    static async find_one(condition) {
      return await this.getone(condition);
    }

    getDetail(id) {
      let condition = {
        //返回的字段  
        attributes: ['id', 'name', 'role'],
        //查询的条件
        where: {
          id: id
        }
      }
      return this.getone(condition);
    }
  }

  m_admin.init(
    {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      name: { type: DataTypes.STRING(45) },
      pwd: { type: DataTypes.STRING(45) },
      role: { type: DataTypes.INTEGER }
    }, {
      sequelize,
      modelName: 'admin',
      freezeTableName: true,
      timestamps: false
    })

    return m_admin;

}

